<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Validator;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return view('welcome');
});

Auth::routes();

Route::get('/home', 'HomeController@index')->name('home');

Route::get('/post-test', 'HomeController@postTest1');
Route::post('/post-test', 'HomeController@postTest2');

Route::get('/user/session', function (Request $request) {
	// echo '<pre>';
	// dd($request->session()->all());
	// dd(Auth::user());
	var_dump(Auth::id());
});


Route::get('/date', function (Request $request) {
	var_dump('date');
	echo "<br/>";
	var_dump(date('Y-d-m H:i:s'));
});

Route::get('/validate', function (Request $request) {
	$request->validate([
		'age' => 'required'
	]);
	var_dump('validate');
	echo "<br/>";
	var_dump(date('Y-d-m H:i:s'));
});

Route::get('/validator', function (Request $request) {
	// $request->validate([
	// 	'age' => 'required'
	// ]);

	$validator = Validator::make($request->all(), [
	    // 'title' => 'required|unique:posts|max:255',
	    // 'body' => 'required',
	    'age' => 'required'
	]);

	var_dump('validator');
	echo "<br/>";
	var_dump(date('Y-d-m H:i:s'));
	echo "<br/>";
	$errors = $validator->errors();
	var_dump($errors);
	echo "<br/>";
	echo $errors->first('age');
});